#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <error.h>
#include <limits.h>
#include <unistd.h>
#include <signal.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <pthread.h>



/*
 * 打印所有可能的sysconf and pathconf值.
 */

int errno;

static void pr_sysconf(char *, int);
static void pr_pathconf(char *, char *, int);

int main(int argc, char ** argv)
{
	if ( argc != 2)
		perror("usage : a.out <dirname>");

#ifdef ARG_MAX
	printf("ARG_MAX defined to be %d\n", ARG_MAX+0);
#else
	printf("no symbol for ARG_MAX\n");
#endif


#ifdef _SC_ARG_MAX
	pr_sysconf("ARG_MAX = ", _SC_ARG_MAX);
#else
	printf("no symbol for _SC_ARG_MAX\n");
#endif

/* similar processing for all the rest of the sysconf symbols ... */
#ifdef MAX_CANON
	printf("MAX_CANON defined to be %d\n", MAX_CANON + 0);
#else
	printf("no symbol for MAX_CANON\n");
#endif

#ifdef _PC_MAX_CANON
	pr_pathconf("MAX_CANON = ", argv[1], _PC_MAX_CANON);
#else
	printf("no symbol for _PC_MAX_CANON\n");
#endif

	/* similar processing for all the rest of the sysconf symbols ... */

	exit(0);
}

static void pr_sysconf(char * mesg, int name)
{
/*	long val;

	fputs(mesg, stdout);
	errno = 0;

	if (( val = sysconf(name)) < 0) {
		if (errno != 0) {
			if (errno == EINVAL)
				fputs("	(not supported)\n", stdout);
			else
				perror("sysconf error");
		}
		else
			printf("%ld\n", val);
	}*/
}

static void pr_pathconf(char * mesg, char * path, int name)
{
/*	long val;

	fputs(mesg, stdout);
	errno = 0;

	if (( val = pathconf(path, name)) < 0) {
		if (errno != 0) {
			if (errno == EINVAL)
				fputs(" (not supported)\n", stdout);
			else
				perror("pathconf error, path = %s", path);
		}
		else
			fputs(" (no limit)\n", stdout);
	}
	else
		printf(" %ld\n", val);*/
}




